﻿using FarmSmartSleep.Common.Domain.BeginTable;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.SleepInfoCommands.RecordCommands
{
    /// <summary>
    /// 后裔耳号信息查询处理
    /// </summary>
    public class ProBeginEarSearchHander : IRequestHandler<ProBeginEarSearchCommand, ResultT<SleepInfor>>
    {
        /// <summary>
        /// 羊只档案仓储接口
        /// </summary>
        private readonly IBaseRepository<SleepInfor> sleepInforRepository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="sleepInforRepository">羊只档案</param>
       public ProBeginEarSearchHander(IBaseRepository<SleepInfor> sleepInforRepository)
        {
            this.sleepInforRepository = sleepInforRepository;
        }



        /// <summary>
        /// 获取后裔耳号信息方法
        /// </summary>
        /// <param name="request">获取后裔耳号信息方法请求对象</param>
        /// <param name="cancellationToken">异步操作可以被取消</param>
        /// <returns>获取后裔耳号方法响应对象</returns>
        public async Task<ResultT<SleepInfor>> Handle(ProBeginEarSearchCommand request, CancellationToken cancellationToken)
        {

            try
            {
                var result = new ResultT<SleepInfor>();
                result.Data =  sleepInforRepository.GetAll().Where(c => c.SleepTypeId == 3).ToList();
                return result;
            }
            catch (Exception ex)
            {

                throw;
            }

        }
    }
}
